<template>
  <div class="container">
    <div class="header">
      <el-row :gutter="20">
        <el-col :span="6">【题型】:123</el-col>
        <el-col :span="6">【编号】:{{detail.subjectID}}</el-col>
        <el-col :span="6">
          【难度】:
          <span v-if="detail.difficulty=='1'">简单</span>
          <span v-else-if="detail.difficulty=='2'">一般</span>
          <span v-else>困难</span>
        </el-col>
        <el-col :span="6">【标签】:{{detail.tags}}</el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top:10px;margin-bottom:10px">
        <el-col :span="6">【学科】:{{detail.subjectName}}</el-col>
        <el-col :span="6">【目录】:{{detail.directoryName}}</el-col>
        <el-col :span="6">【方向】:{{detail.direction}}</el-col>
      </el-row>
    </div>
    <el-divider></el-divider>
    <div class="main">
      <div class="wenti" style="margin-top:10px">【题干】:</div>
      <div class="author" v-html="detail.question" style="color:#1818ff"></div>
      <div class="xuanxiang">
        <span v-if="detail.questionType=='1'">单选题</span>
        <span v-else-if="detail.questionType=='2'">多选题</span>
        <span v-else>简答</span>选项：（以下选中的选项为正确答案）
      </div>
      <div class="danxuan">
        <el-radio-group v-model="checkList[0]" v-if="detail.questionType=='1'">
          <el-radio
            style="display:block;margin-bottom:10px"
            :label="item.code"
            v-for="(item,index) in detail.options"
            :key="index"
          >{{item.title}}</el-radio>
        </el-radio-group>
        <el-checkbox-group v-model="checkList" v-else-if="detail.questionType=='2'">
          <el-checkbox
            style="display:block;margin-bottom:10px"
            :label="item.code"
            v-for="(item,index) in detail.options"
            :key="index"
          >{{item.title}}</el-checkbox>
        </el-checkbox-group>
        <div v-else></div>
      </div>
    </div>
    <el-divider></el-divider>
    <div class="daan" style="margin:10px 0">
      【参考答案】:
      <el-button type="danger" @click="video">视频答案预览</el-button>
    </div>
    <my-video :sources="detail.videoURL" v-if="videoFlag" style="width:300px;margin-bottom:10px"></my-video>
    <el-divider></el-divider>
    <div class="daan">
      【答案解析】:
      <span class="answer" v-html="detail.answer"></span>
    </div>
    <el-divider></el-divider>
    <div class="daan" style="margin-top:10px">【题目备注】:{{detail.remarks}}</div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="$emit('visible')">关闭</el-button>
    </span>
  </div>
</template>

<script>
import { detail } from "@/api/hmmm/questions.js";
import myVideo from "vue-video";
export default {
  props: {
    dialogVisible: {
      type: Boolean,
    },
    viewID: {
      type: [String, Number],
    },
  },
  data() {
    return {
      // radio: "",
      detail: "",
      videoFlag: false,
      checkList: [],
    };
  },
  created() {
    this.getdetail();
  },
  methods: {
    // 获取试题详情
    async getdetail() {
      const { data } = await detail({ id: this.viewID });
      console.log(data, "视频预览");
      this.detail = data;
      data.options.forEach((item) => {
        if (item.isRight == 1) {
          // this.radio = item.code;
          this.checkList.push(item.code);
        }
      });
      console.log(this.checkList, "循环");
    },

    // 显示视频
    video() {
      this.videoFlag = true;
    },
  },
  components: {
    myVideo,
  },
};
</script>

<style scoped lang='scss'>
.container {
  overflow: hidden;
}
::v-deep .el-divider--horizontal {
  margin: 0;
}
.xuanxiang {
  margin-bottom: 10px;
}
.answer {
  ::v-deep p {
    display: inline-block;
  }
}
.dialog-footer {
  display: block;
  margin-top: 20px;
  float: right;
}
</style>
